package com.why.zing.alipay.builder;


import com.why.zing.alipay.util.GsonFactory;

/**
 * 请求体构造父类
 *
 * @author 睁眼看世界
 * @date 2020年1月9日
 */
public abstract class AbstractRequestBuilder {


    private String appAuthToken;
    private String notifyUrl;


    /**
     * 验证请求对象
     */
    public abstract boolean validate();

    /**
     * 获取bizContent对象，用于下一步转换为json字符串
     */
    public abstract Object getBizContent();

    /**
     * 将bizContent对象转换为json字符串
     */
    public String toJsonString() {
        return GsonFactory.getGson().toJson(this.getBizContent());
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("RequestBuilder{");
        sb.append("appAuthToken='").append(appAuthToken).append('\'');
        sb.append(", notifyUrl='").append(notifyUrl).append('\'');
        sb.append('}');
        return sb.toString();
    }

    public String getAppAuthToken() {
        return appAuthToken;
    }

    public AbstractRequestBuilder setAppAuthToken(String appAuthToken) {
        this.appAuthToken = appAuthToken;
        return this;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public AbstractRequestBuilder setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
        return this;
    }
}
